import React from 'react'

export default class Toggle extends React.Component {
  constructor (props) {
    super(props)
    this.state = {
      flag: false
    }

    this.handler = this.handler.bind(this)
  }

  handler () {
    const { flag } = this.state
    this.setState({
      flag: !flag
    })
  }

  render () {
    console.log(this);
    // const _this = JSON.stringify(this)
    return (
      <button onClick={this.handler}>{this.state.flag ? '开' : '关'}</button>
    )
  }
}